<template>
	<view class="index">
		<hand title="网易云音乐" :icon='false'></hand>
		<view class="container">
			<scroll-view scroll-y="true">
			<!-- 	<view v-for="(item,index) in 100" :key="index">测试</view> -->
			<!-- 搜索框 -->
			<view class="index-search" @tap="handTOSearch">
				<text class="iconfont icon-Magnifier"></text>
				<input type="text" placeholder="搜索歌曲">
				
			</view>
			<view v-if="isloading">
				<m-for-skeleton
				        :avatarSize="200"
				        :row="3"
				        :loading="isloading"
				        isarc="square"
				        v-for="(item,key) in 4"
					:titleStyle="{}"
					:title="false"
				        :key="key">
				      
				        </m-for-skeleton>
				       
			</view>
			
			<!-- 卡片 -->
			<view class="index-list" v-else>
				<view class="index-list-item" v-for="(item,index) in topList" :key="index" @tap="handToList(item.id)">
					<view class="index-list-img">
						<image :src="item.coverImgUrl" mode=""></image>
						<text>{{item.updateFrequency}}</text>
						
					</view>
					<view class="index-list-text" >
						<view class="index-list-text-texts" v-for="(items,index) in item.tracks" :key="index">{{index+1}}.{{items.first}}-{{items.second}}</view>
						
						
					</view>
				</view>
				
				
			</view>
			</scroll-view>
			
		</view>
	</view>
</template>

<script>
	import '@/common/iconfont.css'
	import hand from "../../components/miuschead/miuschead.vue"
	import { apis } from "../../common/api.js"
	// 导入组件
	import mForSkeleton from "@/components/m-for-skeleton/m-for-skeleton";
	export default {
		data() {
			return {
				topList:[],
				isloading:true
			}
		},
		onLoad() {
apis.topList().then((res)=>{
	if (res.length) {
		setTimeout(()=>{
		this.topList=res	
		this.isloading=false
		},500) //加载优化可以调节
		
		
	} 
	// console.log(res);
})
		},
		methods: {
handToList(listId){
	console.log(listId);
	uni.navigateTo({
		url:"/pages/list/list?listId="+listId
	})
},
handTOSearch(){
	uni.navigateTo({
		url:"/pages/search/search"
	})
}
		},
		components:{
			hand,
			mForSkeleton
		}
	}
</script>

<style scoped>
	/* @import url("../../common/iconfont.css"); */
	.index{}
	.index-search{
		display: flex;
		align-items: center;
		height: 70rpx;
		margin: 70rpx  30rpx 30rpx 30rpx;
		background-color: #f7f7f7;
		border-radius: 50rpx;
	}
	.index-search text{
		font-size: 26rpx;
		margin-right: 26rpx;
		margin-left: 26rpx;
	}
	.index-search input{
		font-size: 28rpx;
		flex: 1;
	}
	.index-list{
		margin: 0 30rpx;
	}
	.index-list-item{
		display: flex;
		margin-bottom: 34rpx;
	}
	.index-list-img{
		width: 212rpx;
		height: 212rpx;
		position: relative;
		border-radius: 30rpx;
		overflow: hidden;
		margin-right:  22rpx ;
		
	}
	.index-list-img image{
		width: 100%;
		height: 100%;
	}
	.index-list-img text{
		position: absolute;
		left: 12rpx;
		bottom: 16rpx;
		color: #fff;
		font-size: 20rpx;
	}
	.index-list-text{
		
		font-size: 24rpx;
		line-height: 66rpx;
	}
	.index-list-text-texts{
		width:450rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>
